package com.xxg.renrencommon.exception;

import com.xxg.renrencommon.exception.exceptionenum.OrderExceptionCodeCodeEnum;
import com.xxg.renrencommon.exception.exceptionenum.ProductExceptionCodeCodeEnum;

/**
 * 订单管理接口异常
 *
 * @author xxg
 * @date 2020/11/16
 */
public class OrderManagerException extends Exception implements ReturnException{
    private final Integer code;
    private final String errorMessage;

    public OrderManagerException(String message) {
        super(message);
        this.code = 500;
        this.errorMessage = message;
    }

    public OrderManagerException(OrderExceptionCodeCodeEnum codeEnum) {
        super(codeEnum.getName());
        this.code = codeEnum.getCode();
        this.errorMessage = codeEnum.getName();
    }

    public OrderManagerException(String message, int code) {
        super(message);
        this.code = code;
        this.errorMessage = message;
    }

    @Override
    public Integer getCode() {
        return this.code;
    }

    @Override
    public String getErrorMessage() {
        return this.errorMessage;
    }
}
